<?php
/*
 *  将该任务推送到消息队列，等待对应的消费者去执行
 *  database 驱动时，返回值为 1|false  ;   redis 驱动时，返回值为 随机字符串|false
 */
namespace app\common\model;

use think\Queue;

class QueueModel
{
    /**
     * 添加任务
     * @param $jobClassName
     * @param $jobData
     * @param string $queueName
     * @return mixed
     */
    public static function addQueue($jobClassName,$jobData,$queueName='workJob'){
        $isPushed = Queue::push( $jobClassName , $jobData , $queueName);
        return $isPushed;
    }

    /**
     * 添加延时任务
     * @param $delay
     * @param $jobClassName
     * @param $jobData
     * @param string $queueName
     * @return mixed
     */
    public static function addLasterQueue($delay,$jobClassName,$jobData,$queueName='workJob'){
        $isPushed = Queue::later($delay, $jobClassName , $jobData , $queueName);
        return $isPushed;
    }
}